<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>药品说明书</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/res/layui/css/layui.css"  media="all">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
    <script type="text/javascript" src="/res/js/jquery-3.4.1.js"></script>
    <script src="/res/js/util.js" charset="utf-8"></script>

</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>药品说明书</legend>
</fieldset>

<form class="layui-form" action="" lay-filter="myform" id="myform" enctype="multipart/form-data">
    <input type="hidden" name="drugId" >
    <div class="layui-form-item">
        <label class="layui-form-label">药品名称</label>
        <div class="layui-input-block">
            <input type="text" name="drugName" lay-verify="title" autocomplete="off" placeholder="请输入药品名称" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">药品成分</label>
        <div class="layui-input-block">
            <input type="text" name="spConstituen" lay-verify="matter" autocomplete="off" placeholder="请输入药品成分" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">药品性状</label>
        <div class="layui-input-block">
            <input type="text" name="spCharacter" lay-verify="matter" autocomplete="off" placeholder="请输入药品性状" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">作用类别</label>
        <div class="layui-input-block">
            <input type="text" name="useClasses"  lay-verify="matter" autocomplete="off" placeholder="请输入作用类别" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">适应症</label>
        <div class="layui-input-block">
            <input type="text" name="adaptationDisease" lay-verify="matter" autocomplete="off" placeholder="请输入适应症" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">规格</label>
        <div class="layui-input-block">
            <input type="text" name="specification" lay-verify="matter" autocomplete="off" placeholder="请输入规格" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">用法用量</label>
        <div class="layui-input-block">
            <input type="text" name="usageDosage" lay-verify="matter" autocomplete="off" placeholder="请输入用法用量" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">不良反应</label>
        <div class="layui-input-block">
            <input type="text" name="adverseReaction" lay-verify="matter" autocomplete="off" placeholder="请输入不良反应" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">禁忌</label>
        <div class="layui-input-block">
            <input type="text" name="taboo" lay-verify="matter" autocomplete="off" placeholder="请输入禁忌" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">注意事项</label>
        <div class="layui-input-block">
            <input type="text" name="attentionMatter" lay-verify="matter" autocomplete="off" placeholder="请输入注意事项" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">相互作用</label>
        <div class="layui-input-block">
            <input type="text" name="mutualEffect" lay-verify="matter" autocomplete="off" placeholder="请输入相互作用" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">储藏</label>
        <div class="layui-input-block">
            <input type="text" name="store" lay-verify="matter" autocomplete="off" placeholder="请输入储藏" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">包装</label>
        <div class="layui-input-block">
            <input type="text" name="packaging" lay-verify="matter" autocomplete="off" placeholder="请输入包装" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">有效期</label>
        <div class="layui-input-block">
            <input type="text" name="validity" lay-verify="matter" autocomplete="off" placeholder="请输入有效期" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">执行标准</label>
        <div class="layui-input-block">
            <input type="text" name="executeStandard" lay-verify="matter" autocomplete="off" placeholder="请输入执行标准" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">批准文号</label>
        <div class="layui-input-block">
            <input type="text" name="ratifyNumber" lay-verify="matter" autocomplete="off" placeholder="请输入批准文号" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>

<script src="/res/layui/layui.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    //全局同步
    /* $.ajaxSetup({
      async: false
    }); */

    layui.use(['form', 'layedit', 'laydate'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate


        //自定义验证规则
        form.verify({
            title: function(value){
                if(value.length < 1){
                    return '标题至少得1个字符啊';
                }
                if (value.length > 50) {
                    return '填入过长';
                }
            }
            ,matter: function(value){
                if (value.length > 500) {
                    return '填入过长';
                }
            }
        });


        //监听提交
        form.on('submit(demo1)', function(data){
            var loa ;
            var url = "/hqDrug/updateSep";
            var formData = new FormData(document.getElementById("myform"));
            $.ajax({
                url : url,
                data : formData,
                processData : false,
                contentType : false,
                dataType : 'json',
                type : 'POST',
                beforeSend:function(){
                    loa = layer.load(0,{shade:true,time: 8*1000});
                },
                success : function(bm){
                    if(bm.status==1){
                        layer.close(loa);
                        parent.closeOpen(bm.message);
                    }
                },
                error : function(){

                }

            });

            return false;
        });

//表单赋值
        var drugId = getQueryString("id");
        if(drugId){
            var url = "/hqDrug/selectSpec";
            var data = {id:drugId};
            $.post(url,data,function(obj){
                console.info(obj);
                form.val('myform',obj);
            },"json")
        }
    });
</script>

</body>
</html>